package com.example.payment.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class StrategyFactory {

    private final Map<String, PayTypeStrategy> strategyMap;

    @Autowired
    public StrategyFactory(Map<String, PayTypeStrategy> strategyMap) {
        this.strategyMap = strategyMap;
    }

    public PayTypeStrategy getStrategy(String type){
        return switch (type) {
            case "Cash" -> strategyMap.get("cashStrategyImpl");
            case "zfb" -> strategyMap.get("alipayStrategyImpl");
            default -> null;
        };
    }

//    public static StrategyFactory getInstance(ApplicationContext context) {
//        return context.getBean(StrategyFactory.class);
//    }
}
